﻿using System;
using System.Collections.Generic;

using System.Text;
using HZ.DrugTrade.IBLL;
using HZ.DrugTrade.Model;
using HZ.DrugTrade.DAL;
using System.Data;

namespace HZ.DrugTrade.BLL
{
    [Serializable]
    /// <summary>
    /// 操作业务逻辑类,实现接口IBLL_SelectArea,继承自类MarshalByRefObject
    /// </summary>
    public class BLL_SelectArea : MarshalByRefObject, IBLL_SelectArea
    {
        /// <summary>
        /// 根据配送企业编号获取企业的可配送区域
        /// </summary>
        /// <param name="CompanyID_PS">配送企业编号</param>
        /// <returns>区域信息集合</returns>
        public IList<SelectArea> GetAllCity(string CompanyID_PS)
        {
            int totalRecord = 0;
            SelectArea sarea = new SelectArea()
            {
                CompanyID_PS = CompanyID_PS
            };
            return DAL_SelectArea.GetCompanyByWhere(sarea, 1, 0, out totalRecord);
        }

        /// <summary>
        /// 增加
        /// </summary>
        /// <param name="selectArea"></param>
        /// <returns></returns>
        public int AddSelectArea(HZ.DrugTrade.Model.SelectArea selectArea)
        {
            BLL_UserSession.CheckSession();
            int result = DAL.DAL_SelectArea.AddSelectArea(selectArea);
            if(result>0)
            {
                BLL_Log.Instance.AddKeyOperationLog(new KeyOperationLog() { OperateMessage = string.Format("添加配送企业{0}", selectArea.CompanyID_PS) }); 
            }
            return result;
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="selectArea"></param>
        /// <returns></returns>
        public int UpdateSelectArea(HZ.DrugTrade.Model.SelectArea selectArea)
        {
            BLL_UserSession.CheckSession();

            int result = DAL.DAL_SelectArea.UpdateSelectArea(selectArea);
            if (result > 0)
            {
                BLL_Log.Instance.AddKeyOperationLog(new KeyOperationLog() { OperateMessage = string.Format("更新配送企业{0}", selectArea.CompanyID_PS) });
            }
            return result;
        }
    }
}
